package org.coco24.pmstudio.data;

import com.badlogic.gdx.files.FileHandle;
import org.coco24.pmstudio.pack.Pokemon;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;

public class Project implements Serializable
{
    public ArrayList<Pokemon> pokemons;
    public Project()
    {
        pokemons = new ArrayList<>();
    }
    public static Project from(FileHandle fileHandle) throws IOException, ClassNotFoundException
    {
        ObjectInputStream objectInputStream = new ObjectInputStream(fileHandle.read());
        return (Project) objectInputStream.readObject();
    }
    public void to(FileHandle fileHandle) throws IOException
    {
        ObjectOutputStream objectInputStream = new ObjectOutputStream(fileHandle.write(false));
        objectInputStream.writeObject(this);
        objectInputStream.close();
    }
}
